package com.itheima;

import java.util.Random;
import java.util.Scanner;

public class Game {
    public static void main(String[] args) {
        System.out.println("游戏开始");
        Random random = new Random();
        int randomNum = random.nextInt(100) + 1;
        System.out.println("电脑随机数：" + randomNum);
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        int num = sc.nextInt();
        while (true){
            if (num > randomNum){
                System.out.println("猜大了");
                num = sc.nextInt();
            }else{
                System.out.println("猜小了");
                num = sc.nextInt();
            }
            if(num == randomNum){
                System.out.println("恭喜你猜对了");
                break;
            }
        }
    }
}
